<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="高考倒计时.css">
</head>
<body>
    <div class="container">
        <h2><span>Countdown to NCEE</span> 2021</h2>
        <div class="countdown">
            <div id="day">NA</div>
            <div id="hour">NA</div>
            <div id="minute">NA</div>
            <div id="second">NA</div>
        </div>
    </div>

</body>
</html>
<script type="text/javascript">
// 高考日期
function getEndTime(myYear){
   var myEndTime = new Date(''+myYear+'/06/07 00:00:00');
   return myEndTime;
}

function countDown(){
   var mydate = new Date();
   var year = '2022';
   var EndTime = getEndTime(year);
   var NowTime = new Date();
//    如果小于 加一年
   if( (EndTime.getTime() - NowTime.getTime() ) < 0){
       year = mydate.getFullYear() + 1;
       EndTime = getEndTime(year);
   }
   var t = EndTime.getTime() - NowTime.getTime();

   var d=Math.floor(t/1000/60/60/24);
   var h=Math.floor(t/1000/60/60%24);
   var m=Math.floor(t/1000/60%60);
   var s=Math.floor(t/1000%60);

   document.getElementById('day').innerText = d;
   document.getElementById('hour').innerText = h;
   document.getElementById('minute').innerText = m;
   document.getElementById('second').innerText = s;
} 
// 每秒显示一次文本
setInterval(countDown,1000);
</script>
</body>
</html>